<?php
class loginController extends Controller{
    
    private $svc=null;
    
    public function __construct(){
        parent::__construct();
        $this->svc=load_service('i_member_login');
    }
    //检查一下是否已经登陆
    public function c(){
       if($this->svc->user_session('ISLOGIN')){
            alert('您已经登陆！');
            jump('index','index');
       }
	}
    //会员登陆
    public function login(){
        $this->c();
        include($this->viewer_dir.'login/login.php');
    }
    //
    public function login_(){
        $this->c();
        if($_POST){
			$member=load_service('member');
			$member->active($_POST['user_name']);
			
    		$r=$this->svc->user_login($_POST);
    		switch($r){
    			case 1:
    			jump('lesson_list','index');
    			break;
    			case -1:
    			alert('用户不存在！');
                back();
    			break;
    			case -2:
    			alert('密码不正确！');
                back();
    			break;
    			case -3:
    			alert('未知错误！');
                back();
    			break;
    			
    		}
      }
    }
    //安全退出
    public function logout(){
        echo '正在退出，请稍候...';
        $this->svc->user_logout();
        //jump('login','login');
		jump('index','index');
    }
    
}